/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 jfinal app. jfapp Group.
 */

define(['adminapp'], function ($app) {
    $app.navactive('game_category');
    var action_tpl = Handlebars.compile($(g.actiontpl).html());
    var enable_tpl = Handlebars.compile($(g.enabletpl).html());
    var nonenable_tpl = Handlebars.compile($(g.nonenabletpl).html());

    $app.listtable({
        'sAjaxSource' : g.ctx + "admin/game/category/list",
        'bSort' : false,
        'aoColumns'   : [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'name' },
            {'mDataProp': 'enable' }
        ],
        'aoColumnDefs': [
            {
                'aTargets': [3],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                   if (full["enable"]) {
                       return enable_tpl(full);
                   } else {
                       return nonenable_tpl(full);
                   }
                }
            },
            {
                'aTargets': [4],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    return action_tpl(full);
                }
            }
        ]
    }, 'data-list');
});

